package com.example.higo.persenter.homepage;


import com.example.higo.api.service.BaseSubscriber;
import com.example.higo.api.service.ExceptionHandle;
import com.example.higo.model.ModelFactory;
import com.example.higo.model.entity.homepage.HomePageBody;
import com.example.higo.model.entity.homepage.HomePageTab;
import com.example.higo.persenter.BasePersenter;
import com.example.higo.view.imp.homepage.HomePageView;

/**
 * Created by wj on 2016/11/6.
 */

public class HomePagePersenter implements BasePersenter {
    @Override
    public void start() {

    }

    private HomePageView homePageView;

    public HomePagePersenter(HomePageView homePageView) {
        this.homePageView = homePageView;
    }

    public void getHomePageTabData() {
        ModelFactory.getIHomePageModel().getHomePageTabModel(new BaseSubscriber<HomePageTab>() {
            @Override
            public void onSuccess(HomePageTab homePageTab) {
                homePageView.onSuccessTab(homePageTab);
            }

            @Override
            public void onFinish() {
                homePageView.onFinish();
            }

            @Override
            public void onFail(ExceptionHandle.ResponeThrowable e) {
                homePageView.onFail(e);
            }
        });

    }

    public void getHomePageBodyData(String page) {
        ModelFactory.getIHomePageModel().getHomePageBodyModel(new BaseSubscriber<HomePageBody>() {

            @Override
            public void onSuccess(HomePageBody homePageBody) {
                homePageView.onSuccessBody(homePageBody);
            }

            @Override
            public void onFinish() {
                homePageView.onFinish();
            }

            @Override
            public void onFail(ExceptionHandle.ResponeThrowable e) {
                homePageView.onFail(e);
            }
        }, page);

    }
}
